package com.moli.iov.down.command.design.factory.param;

import com.moli.iov.down.enums.command.TerminalSettingEnum;
import com.moli.iov.down.command.design.command.param.setting.SettingDataEncoderCommand;
import com.moli.iov.down.command.design.command.param.setting.impl.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  参数设置编码 工厂
 * </p>
 *
 * @author: zql
 * @Date: 2019/4/28 8:59
 */
public class SettingEncoderFactory {

    private static  final Logger logger = LoggerFactory.getLogger(SettingEncoderFactory.class);

    private static final Map<String, SettingDataEncoderCommand> SETTING_ENCODER_MAP = new HashMap<>();
    
    static{
        SETTING_ENCODER_MAP.put(TerminalSettingEnum.TERMINAL_SERIAL_NUMBER.getFlag(), new GeneralEncoderCommand());
        SETTING_ENCODER_MAP.put(TerminalSettingEnum.TERMINAL_MODEL.getFlag(), new GeneralEncoderCommand());
        SETTING_ENCODER_MAP.put(TerminalSettingEnum.SUPPLIER.getFlag(), new GeneralEncoderCommand());
        SETTING_ENCODER_MAP.put(TerminalSettingEnum.ICCID.getFlag(), new GeneralEncoderCommand());
        SETTING_ENCODER_MAP.put(TerminalSettingEnum.MSISDN.getFlag(), new GeneralEncoderCommand());
        SETTING_ENCODER_MAP.put(TerminalSettingEnum.SOFTWARE_VERSION.getFlag(), new GeneralEncoderCommand());
        SETTING_ENCODER_MAP.put(TerminalSettingEnum.HARDWARE_VERSION.getFlag(), new GeneralEncoderCommand());
        SETTING_ENCODER_MAP.put(TerminalSettingEnum.VIN.getFlag(), new GeneralEncoderCommand());
        SETTING_ENCODER_MAP.put(TerminalSettingEnum.IP.getFlag(), new GeneralEncoderCommand());

        SETTING_ENCODER_MAP.put(TerminalSettingEnum.LEASING_MODE.getFlag(), new LeasingModeEncoderCommand());
        SETTING_ENCODER_MAP.put(TerminalSettingEnum.PORT.getFlag(), new PortEncoderCommand());
        SETTING_ENCODER_MAP.put(TerminalSettingEnum.DATA_FREQUENCY.getFlag(), new DataFrequencyEncoderCommand());

        SETTING_ENCODER_MAP.put(TerminalSettingEnum.BLUETOOTH_PWD.getFlag(), new BluetoothPwdEncoderCommand());
        SETTING_ENCODER_MAP.put(TerminalSettingEnum.BLUETOOTH_VALID_TIME.getFlag(), new BluetoothValidTimeEncoderCommand());
    }
    private SettingEncoderFactory(){}

    /**
     * 获取 参数查询 响应解析 对象
     * @param command
     * @return
     */
    public static SettingDataEncoderCommand getSettingDataEncoderCommand(String command){
        SettingDataEncoderCommand settingDataEncoderCommand = SETTING_ENCODER_MAP.get(command);
        if(settingDataEncoderCommand == null){
            logger.error("[参数设置编码 工厂] 参数设置编码 失败，无当前编码 ParamId：{}", command);
        }
        return settingDataEncoderCommand;
    }
}
